﻿Imports RibbonLib
Imports RibbonLib.Interop
Imports RibbonLib.Controls
Imports RibbonLib.Controls.Events
Imports WebSitePanel.SkinDesigner.Business
Public Class frmMain
    Implements IRibbonForm
    Public Event loaded()
#Region "Private Declarations"
    Public WithEvents _designer As Designer
    Private WithEvents b As ucBrowser
    Private _updateimages As Boolean = True
    Private _handlecommands As Boolean = False
#End Region
#Region "Form Events"
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.Modifiers = Keys.Control Then
            If e.KeyCode = Keys.Z Then
                _designer.Undo()
            ElseIf e.KeyCode = Keys.Y Then
                _designer.Redo()
            End If
        Else
            Debug.WriteLine(e.Modifiers.ToString)
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        cbTopMenuSplitterWidth.RepresentativeString = "XXX"
        cbTopMenuBottomBorderWidth.RepresentativeString = "XXX"
        cbTopMenuTopBorderWidth.RepresentativeString = "XXX"
        cbTopMenuHeight.RepresentativeString = "XXXX"
        cbDocumentBackgroundGradientColor.RepresentativeString = "XXXX"
        cbDocumentBackgroundGradientColor1Transparent.RepresentativeString = "XXXX"
        cbDocumentBackgroundGradientColor2Transparent.RepresentativeString = "XXXX"
        cbPageBorderWidth.RepresentativeString = "XXX"
        cbBreadCrumbBorderWidth.RepresentativeString = "XXX"
        cbSecondaryMenuPosition.RepresentativeString = "XXX"
        cbTopMenuGlowMode.RepresentativeString = "XXXXXXXXXXXXXX"
        cbContainerGlowMode.RepresentativeString = "XXXXXXXXXXXXXX"
        cbSecondaryMenuGlowMode.RepresentativeString = "XXXXXXXXXXXXXX"
        cbRightPanelPosition.RepresentativeString = "XXX"
        cbSecondaryMenuPosition.RepresentativeString = "XXXXX"

        InitComboBox(cbDocumentBackgroundGradientColor, "Height", 0, 600, 10)
        InitComboBox(cbOffset, "Height", 0, 50, 5)
        InitComboBox(cbPadding, "Width", 0, 9, 1)
        InitComboBox(cbDocumentBackgroundGradientColor1Transparent, "Value", 0, 100, 1)
        InitComboBox(cbDocumentBackgroundGradientColor2Transparent, "Value", 0, 100, 1)
        InitComboBox(cbSecondaryMenuPosition, "Position", New List(Of String)(New String() {"Left", "Right"}))
        InitComboBox(cbPageBorderWidth, "Width", 0, 10, 1)
        InitComboBox(cbBreadCrumbBorderWidth, "Width", 0, 10, 1)
        InitComboBox(cbTopMenuHeight, "Height", 30, 100, 2)
        InitComboBox(cbSecondaryMenuTopPadding, "Width", 0, 50, 1)
        InitComboBox(cbSecondaryMenuLeftPadding, "Width", 0, 10, 1)
        InitComboBox(cbSecondaryMenuRightPadding, "Width", 0, 10, 1)
        InitComboBox(cbRightPanelPosition, "Position", 0, 70, 1)
        chkManageIcons.BooleanValue = True
        chkStatusBar.BooleanValue = True
        If Environment.GetCommandLineArgs.Count > 1 AndAlso Environment.GetCommandLineArgs(1).EndsWith(".wsd") Then
            _designer = New Designer(Environment.GetCommandLineArgs(1), ThemeManager.LoadTheme(Environment.GetCommandLineArgs(1)))
        Else
            If Not dialSettings.ShowDialog() = Windows.Forms.DialogResult.OK Then
                Me.Close()
            End If
            _designer = dialSettings.Designer
        End If

        b = New ucBrowser()

        _ribbon.InitFramework(Me)

        RaiseEvent loaded()
        LoadAllValues()
        InitialiseControls()

    End Sub
    Private Sub InitComboBox(ByVal Combobox As RibbonComboBox, ByVal Name As String, ByVal MinValue As Integer, ByVal MaxValue As Integer, ByVal Increment As Integer)
        Combobox.Categories.Add(New GalleryItemPropertySet() With {.Label = Name, .CategoryID = 1})
        For i As Integer = MinValue To MaxValue Step Increment
            Combobox.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = i, .CategoryID = 1})
        Next
    End Sub
    Private Sub InitComboBox(ByVal Combobox As RibbonComboBox, ByVal Name As String, ByVal Values As List(Of String))
        Combobox.Categories.Add(New GalleryItemPropertySet() With {.Label = Name, .CategoryID = 1})
        For Each item As String In Values
            Combobox.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = item, .CategoryID = 1})
        Next
    End Sub
    Public Sub InitialiseControls()
        b.Location = New Point(0, 0)
        scbrowserSidePanel.Panel1.Controls.Add(b)
        b.Dock = DockStyle.Fill
        Me.cbTopMenuSplitterWidth.Categories.Add(New GalleryItemPropertySet() With {.Label = "Width", .CategoryID = 1})
        Me.cbTopMenuBottomBorderWidth.Categories.Add(New GalleryItemPropertySet() With {.Label = "Width", .CategoryID = 1})
        Me.cbTopMenuTopBorderWidth.Categories.Add(New GalleryItemPropertySet() With {.Label = "Width", .CategoryID = 1})
        For i As Integer = 0 To 10
            Me.cbTopMenuSplitterWidth.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = i, .CategoryID = 1})
            Me.cbTopMenuTopBorderWidth.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = i, .CategoryID = 1})
            Me.cbTopMenuBottomBorderWidth.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = i, .CategoryID = 1})
        Next
        FillGlowModeGallery(cbTopMenuGlowMode)
        FillGlowModeGallery(cbContainerGlowMode)
        FillGlowModeGallery(cbSecondaryMenuGlowMode)
        FillBorderGallery(ddgPageBorderStyle)
        FillBorderGallery(ddgBreadCrumbBorderStyle)
    End Sub
    Public Sub BrowserLoaded(ByVal Sender As Object, ByVal e As EventArgs) Handles b.BrowserLoaded
        For Each item As KeyValuePair(Of String, String) In _designer.AllCss
            b.ApplyCss(item.Key, item.Value)
        Next
        AssignRedoUndo()
        If _updateimages Then
            Me.UcImages1.UpdateImages(b.Images)
        End If
        _handlecommands = True
    End Sub
    Public Sub FillBorderGallery(ByVal DropDownGallery As RibbonDropDownGallery)
        DropDownGallery.ItemsSource.Clear()
        DropDownGallery.ItemsSource.Add(New GalleryItemPropertySet With {.ItemImage = _ribbon.ConvertToUIImage(ilBorders.Images(0))})
        DropDownGallery.ItemsSource.Add(New GalleryItemPropertySet With {.ItemImage = _ribbon.ConvertToUIImage(ilBorders.Images(1))})
        DropDownGallery.ItemsSource.Add(New GalleryItemPropertySet With {.ItemImage = _ribbon.ConvertToUIImage(ilBorders.Images(2))})
        DropDownGallery.ItemsSource.Add(New GalleryItemPropertySet With {.ItemImage = _ribbon.ConvertToUIImage(ilBorders.Images(3))})
        DropDownGallery.ItemsSource.Add(New GalleryItemPropertySet With {.ItemImage = _ribbon.ConvertToUIImage(ilBorders.Images(4))})
    End Sub
    Public Sub FillGlowModeGallery(ByVal ComboBox As RibbonComboBox)
        ComboBox.Categories.Add(New GalleryItemPropertySet() With {.Label = "Glow Mode", .CategoryID = 1})
        ComboBox.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = "Gradient", .CategoryID = 1})
        ComboBox.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = "Top Glow", .CategoryID = 1})
        ComboBox.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = "Contrast", .CategoryID = 1})
        ComboBox.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = "Lighten", .CategoryID = 1})
        ComboBox.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = "Darken", .CategoryID = 1})
        ComboBox.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = "Very Light", .CategoryID = 1})
        ComboBox.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = "Very Dark", .CategoryID = 1})
        ComboBox.ItemsSource.Add(New GalleryItemPropertySet() With {.Label = "Solid", .CategoryID = 1})
    End Sub
#End Region
#Region "Ribbon"
    Private _ribbon As New Ribbon
    Private WithEvents btnSave As New RibbonButton(_ribbon, RibbonControls.btnSave)
    Private WithEvents btnExport As New RibbonButton(_ribbon, RibbonControls.btnExport)
    Private WithEvents btnExit As New RibbonButton(_ribbon, RibbonControls.btnExit)
    Private WithEvents cpDocumentBackgroundColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpDocumentBackgroundColor)
    Private WithEvents cpHeaderColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpHeaderColor)
    Private WithEvents cpTopMenuColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpTopMenuColor)
    Private WithEvents fcFooter As New RibbonFontControl(_ribbon, RibbonControls.fcFooter)
    Private WithEvents fcHeader As New RibbonFontControl(_ribbon, RibbonControls.fcHeader)
    Private WithEvents cpContainerTopColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpContainerTopColor)
    Private WithEvents chkManageIcons As New RibbonCheckBox(_ribbon, RibbonControls.chkManageIcons)
    Private WithEvents cpBreadCrumbBackgroundColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpBreadCrumbBackgroundColor)
    Private WithEvents cpSecondaryMenuBackgroundColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpSecondaryMenuBackgroundColor)
    Private WithEvents cpTopMenuSplitterColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpTopMenuSplitterColor)
    Private WithEvents cbTopMenuSplitterWidth As New RibbonComboBox(_ribbon, RibbonControls.cbTopMenuSplitterWidth)
    Private WithEvents cpTopMenuTopBorderColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpTopMenuTopBorderColor)
    Private WithEvents cbTopMenuTopBorderWidth As New RibbonComboBox(_ribbon, RibbonControls.cbTopMenuTopBorderWidth)
    Private WithEvents cpTopMenuBottomBorderColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpTopMenuBottomBorderColor)
    Private WithEvents cbTopMenuBottomBorderWidth As New RibbonComboBox(_ribbon, RibbonControls.cbTopMenuBottomBorderWidth)
    Private WithEvents cpTopMenuRollOverColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpTopMenuHoverColor)
    Private WithEvents cpPageBackgroundColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpPageBackgroundColor)
    Private WithEvents chkStatusBar As New RibbonCheckBox(_ribbon, RibbonControls.chkStatusBar)
    Private WithEvents btnDocumentBackgroundImage As New RibbonButton(_ribbon, RibbonControls.btnDocumentBackgroundImage)
    Private WithEvents chkVerticalRepeat As New RibbonCheckBox(_ribbon, RibbonControls.chkVerticalRepeat)
    Private WithEvents chkHorizontalRepeat As New RibbonCheckBox(_ribbon, RibbonControls.chkHorizontalRepeat)
    Private WithEvents cpFooterLink As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpFooterLink)
    Private WithEvents cpDocumentBackgroundGradientColor1 As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpDocumentBackgroundGradientColor1)
    Private WithEvents cpDocumentBackgroundGradientColor2 As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpDocumentBackgroundGradientColor2)
    Private WithEvents cbDocumentBackgroundGradientColor As New RibbonComboBox(_ribbon, RibbonControls.cbDocumentBackgroundGradientColor)
    Private WithEvents cbDocumentBackgroundGradientColor1Transparent As New RibbonComboBox(_ribbon, RibbonControls.cbDocumentBackgroundGradientColor1Transparent)
    Private WithEvents cbDocumentBackgroundGradientColor2Transparent As New RibbonComboBox(_ribbon, RibbonControls.cbDocumentBackgroundGradientColor2Transparent)
    Private WithEvents btnRemoveDocumentBackgroundImage As New RibbonButton(_ribbon, RibbonControls.btnRemoveDocumentBackgroundImage)
    Private WithEvents btnUndo As New RibbonButton(_ribbon, RibbonControls.btnUndo)
    Private WithEvents btnRedo As New RibbonButton(_ribbon, RibbonControls.btnRedo)
    Private WithEvents cbPadding As New RibbonComboBox(_ribbon, RibbonControls.cbPadding)
    Private WithEvents cbOffset As New RibbonComboBox(_ribbon, RibbonControls.cbOffset)
    Private WithEvents cpPageBorderColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpPageBorderColor)
    Private WithEvents cbPageBorderWidth As New RibbonComboBox(_ribbon, RibbonControls.cbPageBorderWidth)
    Private WithEvents ddgPageBorderStyle As New RibbonDropDownGallery(_ribbon, RibbonControls.ddgPageBorderStyle)
    Private WithEvents fcBreadCrumb As New RibbonFontControl(_ribbon, RibbonControls.fcBreadCrumb)
    Private WithEvents fcBreadCrumbLink As New RibbonFontControl(_ribbon, RibbonControls.fcBreadCrumbLink)
    Private WithEvents cbSecondaryMenuPosition As New RibbonComboBox(_ribbon, RibbonControls.cbSecondaryMenuPosition)
    Private WithEvents cbTopMenuHeight As New RibbonComboBox(_ribbon, RibbonControls.cbTopMenuHeight)
    Private WithEvents cbTopMenuGlowMode As New RibbonComboBox(_ribbon, RibbonControls.cbTopMenuGlowMode)
    Private WithEvents cpTopMenuFontColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpTopMenuFontColor)
    Private WithEvents cpTopMenuFontHoverColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpTopMenuFontHoverColor)
    Private WithEvents cpPageLinkColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpPageLinkColor)
    Private WithEvents cpBreadCrumbBorderColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpBreadCrumbBorderColor)
    Private WithEvents cbBreadCrumbBorderWidth As New RibbonComboBox(_ribbon, RibbonControls.cbBreadCrumbBorderWidth)
    Private WithEvents ddgBreadCrumbBorderStyle As New RibbonDropDownGallery(_ribbon, RibbonControls.ddgBreadCrumbBorderStyle)
    Private WithEvents cbSecondaryMenuTopPadding As New RibbonComboBox(_ribbon, RibbonControls.cbTopPadding)
    Private WithEvents cbSecondaryMenuLeftPadding As New RibbonComboBox(_ribbon, RibbonControls.cbLeftPadding)
    Private WithEvents cbSecondaryMenuRightPadding As New RibbonComboBox(_ribbon, RibbonControls.cbRightPadding)
    Private WithEvents cpContainerBorderColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpContainerBorderColor)
    Private WithEvents chkContainerRoundedCorners As New RibbonCheckBox(_ribbon, RibbonControls.chkContainerRoundedCorners)
    Private WithEvents cbContainerGlowMode As New RibbonComboBox(_ribbon, RibbonControls.cbContainerGlowMode)
    Private WithEvents fcRightPanelTitle As New RibbonFontControl(_ribbon, RibbonControls.fcRightPanelTitle)
    Private WithEvents cbRightPanelPosition As New RibbonComboBox(_ribbon, RibbonControls.cbRightPanelPosition)
    Private WithEvents cpSecondaryMenuHoverColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpSecondaryMenuHoverColor)
    Private WithEvents cpSecondaryMenuHoverBorderColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpSecondaryMenuHoverBorderColor)
    Private WithEvents cbSecondaryMenuGlowMode As New RibbonComboBox(_ribbon, RibbonControls.cbSecondaryMenuGlowMode)
    Private WithEvents chkSecondaryMenuRoundedCorners As New RibbonCheckBox(_ribbon, RibbonControls.chkSecondaryMenuRoundedCorners)
    Private WithEvents fcSecondaryMenuTitle As New RibbonFontControl(_ribbon, RibbonControls.fcSecondaryMenuTitle)
    Private WithEvents fcSecondaryMenuLinks As New RibbonFontControl(_ribbon, RibbonControls.fcSecondaryMenuLinks)
    Private WithEvents cpSecondaryMenuTitleBackgroundColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpSecondaryMenuTitleBackgroundColor)
    Private WithEvents cpSecondaryMenuGradientColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpSecondaryMenuGradientColor)
    Private WithEvents cpSecondaryMenuBorderColor As New RibbonDropDownColorPicker(_ribbon, RibbonControls.cpSecondaryMenuBorderColor)
    Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        UcImages1.Unload()
        If _designer IsNot Nothing Then
            _designer.CloseTheme()
        End If
        Try
            _ribbon.DestroyFramework()
        Catch ex As Exception

        End Try
    End Sub
    Public Sub RibbonHeightUpdated(ByVal newHeight As Integer) Implements RibbonLib.IRibbonForm.RibbonHeightUpdated
        Me.SplitContainer1.SplitterDistance = newHeight
    End Sub
    Public ReadOnly Property WindowHandle As System.IntPtr Implements RibbonLib.IRibbonForm.WindowHandle
        Get
            Return Me.Handle
        End Get
    End Property
#End Region
#Region "Commands"
#Region "Document"
    Private Sub cpDocumentBackgroundColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpDocumentBackgroundColor.OnExecute
        _designer.DocumentBackgroundColor = cpDocumentBackgroundColor.Color
        SetColorIcons(cpDocumentBackgroundColor)
    End Sub
    Private Sub btnDocumentBackgroundImage_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles btnDocumentBackgroundImage.OnExecute
        If ofdImage.ShowDialog = Windows.Forms.DialogResult.OK Then
            _designer.DocumentBackgroundImage = ofdImage.FileName
        End If
    End Sub
    Private Sub chkHorizontalRepeat_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles chkHorizontalRepeat.OnExecute, chkVerticalRepeat.OnExecute
        Dim bgrepeat As BackgroundRepeat
        If chkHorizontalRepeat.BooleanValue AndAlso chkVerticalRepeat.BooleanValue Then
            bgrepeat = BackgroundRepeat.Repeat
        ElseIf chkHorizontalRepeat.BooleanValue And Not chkVerticalRepeat.BooleanValue Then
            bgrepeat = BackgroundRepeat.RepeatX
        ElseIf Not chkHorizontalRepeat.BooleanValue And chkVerticalRepeat.BooleanValue Then
            bgrepeat = BackgroundRepeat.RepeatY
        Else
            bgrepeat = BackgroundRepeat.NoRepeat
        End If
        _designer.DocumentBackgroundRepeat = bgrepeat
    End Sub
    Private Sub cpDocumentBackgroundGradientColor1_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpDocumentBackgroundGradientColor1.OnExecute, cpDocumentBackgroundGradientColor2.OnExecute, cbDocumentBackgroundGradientColor.OnExecute, cbDocumentBackgroundGradientColor1Transparent.OnExecute, cbDocumentBackgroundGradientColor2Transparent.OnExecute
        If _handlecommands Then
            Dim color1 As Color
            Dim color2 As Color
            color1 = Color.FromArgb(ValueFromPercent(cbDocumentBackgroundGradientColor1Transparent.SelectedItem), cpDocumentBackgroundGradientColor1.Color.R, cpDocumentBackgroundGradientColor1.Color.G, cpDocumentBackgroundGradientColor1.Color.B)
            color2 = Color.FromArgb(ValueFromPercent(cbDocumentBackgroundGradientColor2Transparent.SelectedItem), cpDocumentBackgroundGradientColor2.Color.R, cpDocumentBackgroundGradientColor2.Color.G, cpDocumentBackgroundGradientColor2.Color.B)
            Dim gd As New GradientDefinition(color1, color2, CInt(cbDocumentBackgroundGradientColor.SelectedItem * 10))
            _designer.DocumentBackgroundGradient = gd
            SetColorIcons(cpDocumentBackgroundGradientColor1)
            SetColorIcons(cpDocumentBackgroundGradientColor2)
        End If
    End Sub
    Private Sub btnRemoveDocumentBackgroundImage_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles btnRemoveDocumentBackgroundImage.OnExecute
        _designer.RemoveDocumentBackgroundImage()
    End Sub
    Private Sub fcFooter_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles fcFooter.OnExecute
        _designer.FooterFont = GetFont(fcFooter)
    End Sub
    Private Sub cpFooterLink_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpFooterLink.OnExecute
        _designer.FooterLinkColor = cpFooterLink.Color
        SetColorIcons(cpFooterLink)


    End Sub
#End Region
#Region "Top Menu"
    Private Sub cpTopMenu_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpTopMenuColor.OnExecute
        SetColorIcons(cpTopMenuColor)
        _designer.TopMenuBackgroundColor = cpTopMenuColor.Color
    End Sub
    Private Sub cpTopMenuRollOverColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpTopMenuRollOverColor.OnExecute
        _designer.TopMenuHoverColor = cpTopMenuRollOverColor.Color
        SetColorIcons(cpTopMenuRollOverColor)
    End Sub
    Private Sub cbTopMenuSplitterSize_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbTopMenuSplitterWidth.OnExecute
        _designer.TopMenuSplitterWidth = cbTopMenuSplitterWidth.SelectedItem
    End Sub
    Private Sub cpTopMenuSplitterColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpTopMenuSplitterColor.OnExecute
        _designer.TopMenuSplitterColor = cpTopMenuSplitterColor.Color
        Me.SetColorIcons(cpTopMenuSplitterColor)
    End Sub
    Private Sub cbTopMenuTopBorderSize_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbTopMenuTopBorderWidth.OnExecute
        _designer.TopMenuTopBorderWidth = cbTopMenuTopBorderWidth.SelectedItem
    End Sub
    Private Sub cpTopMenuTopBorderColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpTopMenuTopBorderColor.OnExecute
        _designer.TopMenuTopBorderColor = cpTopMenuTopBorderColor.Color
        Me.SetColorIcons(cpTopMenuTopBorderColor)
    End Sub
    Private Sub cbTopMenuBottomBorderSize_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbTopMenuBottomBorderWidth.OnExecute
        _designer.TopMenuBottomBorderWidth = cbTopMenuBottomBorderWidth.SelectedItem
    End Sub
    Private Sub cpTopMenuBottomBorderColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpTopMenuBottomBorderColor.OnExecute
        _designer.TopMenuBottomBorderColor = cpTopMenuBottomBorderColor.Color
        Me.SetColorIcons(cpTopMenuBottomBorderColor)
    End Sub
    Private Sub cbTopMenuHeight_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbTopMenuHeight.OnExecute
        _designer.TopMenuHeight = (cbTopMenuHeight.SelectedItem * 2) + 30
    End Sub
    Private Sub cbGlowMode_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbTopMenuGlowMode.OnExecute
        _designer.TopMenuGlowMode = cbTopMenuGlowMode.SelectedItem
    End Sub
    Private Sub cpTopMenuFontColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpTopMenuFontColor.OnExecute
        _designer.TopMenuFontColor = cpTopMenuFontColor.Color
        Me.SetColorIcons(cpTopMenuFontColor)
    End Sub
    Private Sub cpTopMenuFontHoverColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpTopMenuFontHoverColor.OnExecute
        _designer.TopMenuFontHoverColor = cpTopMenuFontHoverColor.Color
        Me.SetColorIcons(cpTopMenuFontHoverColor)
    End Sub
#End Region
#Region "SecondaryMenu"
    Private Sub cpSecondaryMenu_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpSecondaryMenuBackgroundColor.OnExecute
        SetColorIcons(cpSecondaryMenuBackgroundColor)
        _designer.SecondaryMenuBackgroundColor = cpSecondaryMenuBackgroundColor.Color
    End Sub
    Private Sub cbSecondaryMenuPosition_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbSecondaryMenuPosition.OnExecute
        If cbSecondaryMenuPosition.SelectedItem = 0 Then
            _designer.SecondaryMenuPosition = Position.Left
        Else
            _designer.SecondaryMenuPosition = Position.Right
        End If
    End Sub
    Private Sub cbSecondaryMenuLeftPadding_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbSecondaryMenuLeftPadding.OnExecute
        _designer.SecondaryMenuLeftPadding = cbSecondaryMenuLeftPadding.SelectedItem
    End Sub
    Private Sub cbSecondaryMenuRightPadding_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbSecondaryMenuRightPadding.OnExecute
        _designer.SecondaryMenuRightPadding = cbSecondaryMenuRightPadding.SelectedItem
    End Sub
    Private Sub cbSecondaryMenuTopPadding_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbSecondaryMenuTopPadding.OnExecute
        _designer.SecondaryMenuTopPadding = cbSecondaryMenuTopPadding.SelectedItem
    End Sub
    Private Sub chkSecondaryMenuRoundedCorners_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles chkSecondaryMenuRoundedCorners.OnExecute
        _designer.SecondaryMenuRoundedCorners = chkSecondaryMenuRoundedCorners.BooleanValue
    End Sub
    Private Sub cbSecondaryMenuGlowMode_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbSecondaryMenuGlowMode.OnExecute
        _designer.SecondaryMenuGlowMode = cbSecondaryMenuGlowMode.SelectedItem
    End Sub
    Private Sub cpSecondaryMenuHoverBorderColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpSecondaryMenuHoverBorderColor.OnExecute
        _designer.SecondaryMenuBorderHoverColor = cpSecondaryMenuHoverBorderColor.Color
        SetColorIcons(cpSecondaryMenuHoverBorderColor)
    End Sub
    Private Sub cpSecondaryMenuHoverColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpSecondaryMenuHoverColor.OnExecute
        _designer.SecondaryMenuHoverColor = cpSecondaryMenuHoverColor.Color
        SetColorIcons(cpSecondaryMenuHoverColor)
    End Sub
    Private Sub fcSecondaryMenuLinks_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles fcSecondaryMenuLinks.OnExecute
        _designer.SecondaryMenuLinksFont = GetFont(fcSecondaryMenuLinks)
    End Sub
    Private Sub fcSecondaryMenuTitle_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles fcSecondaryMenuTitle.OnExecute
        _designer.SecondaryMenuTitleFont = GetFont(fcSecondaryMenuTitle)
    End Sub
    Private Sub cpSecondaryMenuTitleBackgroundColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpSecondaryMenuTitleBackgroundColor.OnExecute
        _designer.SecondaryMenuTitleBackGroundColor = cpSecondaryMenuTitleBackgroundColor.Color
        SetColorIcons(cpSecondaryMenuTitleBackgroundColor)
    End Sub
    Private Sub cpSecondaryMenuBorderColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpSecondaryMenuBorderColor.OnExecute
        _designer.SecondaryMenuBorderColor = cpSecondaryMenuBorderColor.Color
        SetColorIcons(cpSecondaryMenuBorderColor)
    End Sub
    Private Sub cpSecondaryMenuGradientColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpSecondaryMenuGradientColor.OnExecute
        _designer.SecondaryMenuGradientColor = cpSecondaryMenuGradientColor.Color
        SetColorIcons(cpSecondaryMenuGradientColor)
    End Sub
#End Region
#Region "Page"
    Private Sub cpHeaderColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpHeaderColor.OnExecute
        SetColorIcons(cpHeaderColor)
        _designer.HeaderColor = cpHeaderColor.Color
    End Sub
    Private Sub fcHeader_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles fcHeader.OnExecute
        _designer.HeaderFont = GetFont(fcHeader)
    End Sub
    Private Sub cpPageBackgroundColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpPageBackgroundColor.OnExecute
        _designer.PageBackgroundColor = cpPageBackgroundColor.Color
        SetColorIcons(cpPageBackgroundColor)
    End Sub
    Private Sub spOffset_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbOffset.OnExecute
        _designer.Offset = cbOffset.SelectedItem * 5
    End Sub
    Private Sub spPadding_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbPadding.OnExecute
        _designer.Padding = cbPadding.SelectedItem
    End Sub
    Private Sub ddgPageBorderStyle_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles ddgPageBorderStyle.OnExecute
        _designer.PageBorderStyle = GetBorderString(ddgPageBorderStyle.SelectedItem)
        ddgPageBorderStyle.SmallImage = _ribbon.ConvertToUIImage(ilBorders.Images(CInt(ddgPageBorderStyle.SelectedItem)))
    End Sub
    Private Sub cpPageBorderColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpPageBorderColor.OnExecute
        _designer.PageBorderColor = cpPageBorderColor.Color
        SetColorIcons(cpPageBorderColor)
    End Sub
    Private Sub spPageBorderWidth_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbPageBorderWidth.OnExecute
        _designer.PageBorderWidth = cbPageBorderWidth.SelectedItem
    End Sub
    Private Sub cpPageLinkColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpPageLinkColor.OnExecute
        _designer.PageLinkColor = cpPageLinkColor.Color
        SetColorIcons(cpPageLinkColor)
    End Sub
#End Region
#Region "Containers"
    Private Sub cpContainerTopColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpContainerTopColor.OnExecute
        SetColorIcons(cpContainerTopColor)
        _designer.ContainerColor = cpContainerTopColor.Color
    End Sub
    Private Sub cpContainerBorderColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpContainerBorderColor.OnExecute
        SetColorIcons(cpContainerBorderColor)
        _designer.ContainerBorderColor = cpContainerBorderColor.Color
    End Sub
    Private Sub cbContainerGlowMode_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbContainerGlowMode.OnExecute
        _designer.ContainerGlowMode = cbContainerGlowMode.SelectedItem
    End Sub
    Private Sub chkContainerRoundedCorners_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles chkContainerRoundedCorners.OnExecute
        _designer.ContainerRoundedCorners = chkContainerRoundedCorners.BooleanValue
    End Sub
#End Region
#Region "BreadCrumb"
    Private Sub BreadCrumbBackgroundColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpBreadCrumbBackgroundColor.OnExecute
        SetColorIcons(cpBreadCrumbBackgroundColor)
        _designer.BreadCrumbBackgroundColor = cpBreadCrumbBackgroundColor.Color
    End Sub
    Private Sub fcBreadCrumb_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles fcBreadCrumb.OnExecute
        _designer.BreadCrumbFont = GetFont(fcBreadCrumb)
    End Sub
    Private Sub fcBreadCrumbLink_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles fcBreadCrumbLink.OnExecute
        _designer.BreadCrumbLinkFont = GetFont(fcBreadCrumbLink)
    End Sub
    Private Sub ddgBreadCrumbBorderStyle_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles ddgBreadCrumbBorderStyle.OnExecute
        _designer.BreadCrumbBorderStyle = GetBorderString(ddgBreadCrumbBorderStyle.SelectedItem)
        ddgBreadCrumbBorderStyle.SmallImage = _ribbon.ConvertToUIImage(ilBorders.Images(CInt(ddgBreadCrumbBorderStyle.SelectedItem)))
    End Sub
    Private Sub cpBreadCrumbBorderColor_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cpBreadCrumbBorderColor.OnExecute
        _designer.BreadCrumbBorderColor = cpBreadCrumbBorderColor.Color
        SetColorIcons(cpBreadCrumbBorderColor)
    End Sub
    Private Sub cbBreadCrumbBorderWidth_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbBreadCrumbBorderWidth.OnExecute
        _designer.BreadCrumbBorderWidth = cbBreadCrumbBorderWidth.SelectedItem
    End Sub
#End Region
#Region "RightPanel Title"
    Private Sub fcRightPanelTitle_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles fcRightPanelTitle.OnExecute
        _designer.RightPanelTitleFont = GetFont(fcRightPanelTitle)
    End Sub
    Private Sub cbRightPanelPosition_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles cbRightPanelPosition.OnExecute
        _designer.RightPanelPosition = cbRightPanelPosition.SelectedItem
    End Sub
#End Region
#Region "Other"
    Private Sub btnRedo_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles btnRedo.OnExecute
        _designer.Redo()
    End Sub
    Private Sub btnUndo_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles btnUndo.OnExecute
        _designer.Undo()
    End Sub
    Private Sub LoadAllValues()
        ApplyBackgroundRepeat(chkHorizontalRepeat, chkVerticalRepeat, _designer.DocumentBackgroundRepeat)
        chkContainerRoundedCorners.BooleanValue = _designer.ContainerRoundedCorners
        chkSecondaryMenuRoundedCorners.BooleanValue = _designer.SecondaryMenuRoundedCorners
        ApplyFont(fcFooter, _designer.FooterFont)
        ApplyFont(fcHeader, _designer.HeaderFont)
        ApplyFont(fcBreadCrumb, _designer.BreadCrumbFont)
        ApplyFont(fcBreadCrumbLink, _designer.BreadCrumbLinkFont)
        ApplyFont(fcRightPanelTitle, _designer.RightPanelTitleFont)
        ApplyFont(fcSecondaryMenuLinks, _designer.SecondaryMenuLinksFont)
        ApplyFont(fcSecondaryMenuTitle, _designer.SecondaryMenuTitleFont)
        SetColorPicker(cpTopMenuColor, _designer.TopMenuBackgroundColor)
        SetColorPicker(cpTopMenuRollOverColor, _designer.TopMenuHoverColor)
        SetColorPicker(cpTopMenuBottomBorderColor, _designer.TopMenuBottomBorderColor)
        SetColorPicker(cpTopMenuTopBorderColor, _designer.TopMenuTopBorderColor)
        SetColorPicker(cpTopMenuSplitterColor, _designer.TopMenuSplitterColor)
        SetColorPicker(cpBreadCrumbBackgroundColor, _designer.BreadCrumbBackgroundColor)
        SetColorPicker(cpSecondaryMenuBackgroundColor, _designer.SecondaryMenuBackgroundColor)
        SetColorPicker(cpContainerTopColor, _designer.ContainerColor)
        SetColorPicker(cpHeaderColor, _designer.HeaderColor)
        SetColorPicker(cpDocumentBackgroundColor, _designer.DocumentBackgroundColor)
        SetColorPicker(cpPageBackgroundColor, _designer.PageBackgroundColor)
        SetColorPicker(cpPageBorderColor, _designer.PageBorderColor)
        SetColorPicker(cpFooterLink, _designer.FooterLinkColor)
        SetColorPicker(cpTopMenuFontColor, _designer.TopMenuFontColor)
        SetColorPicker(cpTopMenuFontHoverColor, _designer.TopMenuFontHoverColor)
        SetColorPicker(cpPageLinkColor, _designer.PageLinkColor)
        SetColorPicker(cpBreadCrumbBorderColor, _designer.BreadCrumbBorderColor)
        SetColorPicker(cpContainerBorderColor, _designer.ContainerBorderColor)
        SetColorPicker(cpSecondaryMenuHoverColor, _designer.SecondaryMenuHoverColor)
        SetColorPicker(cpSecondaryMenuHoverBorderColor, _designer.SecondaryMenuBorderHoverColor)
        SetColorPicker(cpSecondaryMenuTitleBackgroundColor, _designer.SecondaryMenuTitleBackGroundColor)
        SetColorPicker(cpSecondaryMenuGradientColor, _designer.SecondaryMenuGradientColor)
        SetColorPicker(cpSecondaryMenuBorderColor, _designer.SecondaryMenuBorderColor)
        ddgPageBorderStyle.SelectedItem = GetBorderID(_designer.PageBorderStyle)
        ddgBreadCrumbBorderStyle.SelectedItem = GetBorderID(_designer.BreadCrumbBorderStyle)

        cbTopMenuBottomBorderWidth.SelectedItem = _designer.TopMenuBottomBorderWidth
        cbTopMenuTopBorderWidth.SelectedItem = _designer.TopMenuTopBorderWidth
        cbTopMenuSplitterWidth.SelectedItem = _designer.TopMenuSplitterWidth
        cbTopMenuHeight.SelectedItem = (_designer.TopMenuHeight - 30) / 2
        cbTopMenuGlowMode.SelectedItem = _designer.TopMenuGlowMode
        cbContainerGlowMode.SelectedItem = _designer.ContainerGlowMode
        cbRightPanelPosition.SelectedItem = _designer.RightPanelPosition
        cbSecondaryMenuGlowMode.SelectedItem = _designer.SecondaryMenuGlowMode

        cbBreadCrumbBorderWidth.SelectedItem = _designer.BreadCrumbBorderWidth
        cbSecondaryMenuTopPadding.SelectedItem = _designer.SecondaryMenuTopPadding
        cbSecondaryMenuRightPadding.SelectedItem = _designer.SecondaryMenuRightPadding
        cbSecondaryMenuLeftPadding.SelectedItem = _designer.SecondaryMenuLeftPadding
        Dim gd As GradientDefinition = _designer.DocumentBackgroundGradient
        SetColorPicker(cpDocumentBackgroundGradientColor1, gd.Color1)
        SetColorPicker(cpDocumentBackgroundGradientColor2, gd.Color2)
        Me.cbDocumentBackgroundGradientColor1Transparent.SelectedItem = PercentFromValue(gd.Color1.A)
        Me.cbDocumentBackgroundGradientColor2Transparent.SelectedItem = PercentFromValue(gd.Color2.A)
        cbDocumentBackgroundGradientColor.SelectedItem = gd.Height / 10

        cbOffset.SelectedItem = _designer.Offset / 5
        cbPadding.SelectedItem = _designer.Padding
        cbPageBorderWidth.SelectedItem = _designer.PageBorderWidth
        If _designer.SecondaryMenuPosition = Position.Left Then
            cbSecondaryMenuPosition.SelectedItem = 0
        Else
            cbSecondaryMenuPosition.SelectedItem = 1
        End If
    End Sub
#End Region
#End Region
#Region "Controls"
    Private Sub AssignRedoUndo()
        Me.btnRedo.Enabled = _designer.CanRedo
        Me.btnUndo.Enabled = _designer.CanUndo
    End Sub
#End Region
#Region "Menu"
    Private Sub btnSave_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles btnSave.OnExecute
        Me.Cursor = Cursors.WaitCursor
        _enablevents = False
        _designer.Save()
        _enablevents = True
        Me.Cursor = Cursors.Default
    End Sub
    Private Sub btnExit_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles btnExit.OnExecute
        End
    End Sub
    Private Sub btnManageIcons_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles chkManageIcons.OnExecute
        Me.scbrowserSidePanel.Panel2Collapsed = Not chkManageIcons.BooleanValue
        _updateimages = chkManageIcons.BooleanValue
        If _updateimages Then
            UcImages1.UpdateImages(b.Images)
        End If
    End Sub
    Private Sub chkStatusBar_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles chkStatusBar.OnExecute
        b.StatusBarVisible = chkStatusBar.BooleanValue
    End Sub
    Private Sub btnExport_OnExecute(ByVal key As RibbonLib.Interop.PropertyKeyRef, ByVal currentValue As RibbonLib.Interop.PropVariantRef, ByVal commandExecutionProperties As RibbonLib.Interop.IUISimplePropertySet) Handles btnExport.OnExecute
        If fbdExport.ShowDialog = Windows.Forms.DialogResult.OK Then
            _designer.ExportTheme(fbdExport.SelectedPath)
        End If
    End Sub
#End Region
#Region "Designer events"
    Private _enablevents As Boolean = True
    Private Sub _designer_CssChanged(ByVal Sender As Object, ByVal e As Business.CssChangedEventArgs) Handles _designer.CssChanged
        If _enablevents Then
            b.ApplyCss(e.Name, e.Text)
            AssignRedoUndo()
        End If
    End Sub
    Private Sub _designer_ImagingChanged(ByVal Sender As Object, ByVal e As System.EventArgs) Handles _designer.ImagingChanged
        If _enablevents Then
            b.ReloadImages()
            For Each item As KeyValuePair(Of String, String) In _designer.AllCss
                b.ApplyCss(item.Key, item.Value)
            Next
            AssignRedoUndo()
        End If
    End Sub
#End Region
#Region "Private Helpers"
    Private Sub SetColorIcons(ByVal ColorPicker As RibbonDropDownColorPicker)
        ColorPicker.LargeImage = _ribbon.ConvertToUIImage(Toolbox.GetLargeColorIcon(ColorPicker.Color))
        ColorPicker.SmallImage = _ribbon.ConvertToUIImage(Toolbox.GetSmallColorIcon(ColorPicker.Color))
    End Sub
    Private Function ToBoolean(ByVal FontUnderline As FontUnderline) As Boolean
        If FontUnderline = Interop.FontUnderline.Set Then
            Return True
        Else
            Return False
        End If
    End Function
    Private Function ToRibbonBoolean(ByVal value As Boolean) As FontUnderline
        If value Then
            Return FontUnderline.Set
        Else
            Return FontUnderline.NotSet
        End If
    End Function
    Private Function ValueFromPercent(ByVal Percent As Integer) As Integer
        Return 255 - (Percent * 2.55)
    End Function
    Private Function PercentFromValue(ByVal Value As Integer) As Integer
        Return 100 - (Value / 2.55)
    End Function
    Private Function GetBorderID(ByVal border As String) As Integer
        Select Case border
            Case "solid"
                Return 0
            Case "dotted"
                return 1
            Case "dashed"
                Return 2
            Case "double"
                Return 3
            Case "groove"
                Return 4
            Case Else
                Return 0
        End Select
    End Function
    Private Function GetBorderString(ByVal ID As Integer) As String
        Select Case ID
            Case 0
                Return "solid"
            Case 1
                Return "dotted"
            Case 2
                Return "dashed"
            Case 3
                Return "double"
            Case 4
                Return "groove"
            Case Else
                Return "solid"
        End Select
    End Function
    Private Sub SetColorPicker(ByVal Picker As RibbonDropDownColorPicker, ByVal Color As Color)
        Picker.Color = Color
        SetColorIcons(Picker)
    End Sub
    Private Sub ApplyFont(ByVal control As RibbonFontControl, ByVal Font As CssFont)
        control.Size = Font.FontSize
        control.ForegroundColor = Font.Color
        control.Bold = ToRibbonBoolean(Font.Bold)
        control.Underline = ToRibbonBoolean(Font.Underline)
        control.Italic = ToRibbonBoolean(Font.Italic)
        control.Family = Font.FontFamily
    End Sub
    Private Function GetFont(ByVal Control As RibbonFontControl) As CssFont
        Return New CssFont(Control.Size, Control.Family, ToBoolean(Control.Bold), ToBoolean(Control.Italic), ToBoolean(Control.Underline), Control.ForegroundColor)
    End Function
    Private Sub ApplyBackgroundRepeat(ByVal RepeatX As RibbonCheckBox, ByVal RepeatY As RibbonCheckBox, ByVal BackgroundRepeat As BackgroundRepeat)
        RepeatX.BooleanValue = False
        RepeatY.BooleanValue = False
        Select Case BackgroundRepeat
            Case Business.BackgroundRepeat.RepeatX
                RepeatX.BooleanValue = True
            Case Business.BackgroundRepeat.RepeatY
                RepeatY.BooleanValue = True
            Case Business.BackgroundRepeat.Repeat
                RepeatX.BooleanValue = True
                RepeatY.BooleanValue = True
        End Select
    End Sub
#End Region
End Class